package cn.stylefeng.guns.sys.modular.system.controller;

import cn.stylefeng.guns.base.pojo.page.LayuiPageInfo;
import cn.stylefeng.guns.sys.modular.system.entity.BtyArea;
import cn.stylefeng.guns.sys.modular.system.model.params.BtyAreaParam;
import cn.stylefeng.guns.sys.modular.system.service.BtyAreaService;
import cn.stylefeng.roses.core.base.controller.BaseController;
import cn.stylefeng.roses.core.reqres.response.ResponseData;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import java.util.Arrays;


/**
 * 控制器
 *
 * @author zxd
 * @Date 2022-07-20 10:54:40
 */
@Controller
@RequestMapping("/btyArea")
public class BtyAreaController extends BaseController {

    private String PREFIX = "/modular/system/btyArea";

    @Autowired
    private BtyAreaService btyAreaService;

    /**
     * 合规
     */
    final private Integer COMPLIANCE = 0;
    /**
     * 不合规
     */
    final private Integer NO_COMPLIANCE = 1;
    /**
     * 跳转到主页面
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("")
    public String index() {
        return PREFIX + "/btyArea.html";
    }

    /**
     * 新增页面
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/add")
    public String add() {
        return PREFIX + "/btyArea_add.html";
    }

    /**
     * 编辑页面
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/edit")
    public String edit() {
        return PREFIX + "/btyArea_edit.html";
    }

    /**
     * 新增接口
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/addItem")
    @ResponseBody
    public ResponseData addItem(BtyAreaParam btyAreaParam) {
        this.btyAreaService.add(btyAreaParam);
        return ResponseData.success();
    }

    /**
     * 编辑接口
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/editItem")
    @ResponseBody
    public ResponseData editItem(BtyAreaParam btyAreaParam) {
        this.btyAreaService.update(btyAreaParam);
        return ResponseData.success();
    }

    /**
     * 删除接口
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/delete")
    @ResponseBody
    public ResponseData delete(BtyAreaParam btyAreaParam) {
        this.btyAreaService.delete(btyAreaParam);
        return ResponseData.success();
    }

    /**
     * 查看详情接口
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/detail")
    @ResponseBody
    public ResponseData detail(BtyAreaParam btyAreaParam) {
        BtyArea detail = this.btyAreaService.getById(btyAreaParam.getId());
        return ResponseData.success(detail);
    }

    /**
     * 查询列表
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @ResponseBody
    @RequestMapping("/list")
    public LayuiPageInfo list(BtyAreaParam btyAreaParam) {
        return this.btyAreaService.findPageBySpec(btyAreaParam);
    }

    /**
     * 修改状态
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/switchStatus")
    @ResponseBody
    public ResponseData switchStatus(BtyAreaParam btyAreaParam) {
        this.btyAreaService.update(btyAreaParam);
        return ResponseData.success();
    }

    /**
     * 批量修改状态
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/batchSwitchStatus")
    @ResponseBody
    public ResponseData batchSwitchStatus(BtyAreaParam btyAreaParam) {
        this.btyAreaService.batchSwitchStatus(btyAreaParam);
        return ResponseData.success();
    }

    /**
     * 根据营运经理查询督导
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/ddList")
    @ResponseBody
    public ResponseData ddList(BtyAreaParam btyAreaParam) {
        return ResponseData.success(this.btyAreaService.ddList(btyAreaParam));
    }

    /**
     * 根据营运经理获取店名
     *
     * @author zxd
     * @Date 2022-07-20
     */
    @RequestMapping("/getShopByYyjl")
    @ResponseBody
    public ResponseData getShopByYyjl(BtyAreaParam btyAreaParam) {
        return ResponseData.success(this.btyAreaService.getShopByYyjl(btyAreaParam));
    }
}


